#ifndef CLIONQT5WORK_IMAGELABEL_H
#define CLIONQT5WORK_IMAGELABEL_H
#include <QLabel>
#include <QMouseEvent>
#include <QPainter>

class ImageLabel : public QLabel {
Q_OBJECT

public:
    explicit ImageLabel(QWidget *parent = nullptr);

    void setPixmapWithScale(const QPixmap& pixmap, float& scaleOut);
    QRect getSelectedRect() const;

signals:
    void regionSelected(QRect rect);

protected:
    void mousePressEvent(QMouseEvent* event) override;
    void mouseMoveEvent(QMouseEvent* event) override;
    void mouseReleaseEvent(QMouseEvent* event) override;
    void paintEvent(QPaintEvent* event) override;

private:
    QPoint startPos, endPos;
    bool selecting = false;
    QPixmap originalPixmap;
};
#endif //CLIONQT5WORK_IMAGELABEL_H
